package com.we.wecc.aw.api.controller;

import com.we.wecc.aw.mid.service.InvestService;
import com.x.share.api.controller.BaseController;
import com.x.share.mid.exception.HelperException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Api("云购投资接口")
@RequestMapping("wecc/aw/")
@RestController
public class InvestController extends BaseController{

    @Resource
    InvestService investService;

    @ApiOperation(value = "云购投资", notes= "云购投资", response = Boolean.class)
    @RequestMapping(value = "/invest", method = { RequestMethod.GET })
    public @ResponseBody
    Map<String, Object> invest(
            @ApiParam(value = "用户id") @RequestParam("userId") Long userId,
            @ApiParam(value = "期数id") @RequestParam("awardId") Integer awardId,
            @ApiParam(value = "应用id") @RequestHeader("appId") String appId,
            @ApiParam(value = "应用accessToken") @RequestHeader("atk") String atk) throws HelperException {
        Boolean flag = investService.invest(userId, awardId);
        return success(flag);
    }

    @ApiOperation(value = "获取公告", notes= "获取公告", response = String.class)
    @RequestMapping(value = "/getProclamation", method = { RequestMethod.GET })
    public @ResponseBody
    Map<String, Object> getProclamation(
            @ApiParam(value = "应用id") @RequestHeader("appId") String appId,
            @ApiParam(value = "应用accessToken") @RequestHeader("atk") String atk) throws HelperException {
        List<String> proclamations = investService.getProclamation();
        return success(proclamations);
    }
}
